﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MutualMemberSumirise.aspx.cs"
    Inherits="GH.Web.Welfare.MutualMemberSumirise" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>欢迎使用工会管理系统</title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            font-size: 16px;
            font-weight: bold;
        }
    </style>
    <style type='text/css'>
        thead
        {
            font-size: 12pt;
            font-weight: bold;
            color: #444;
        }
        tbody
        {
            font-size: 10pt;
            color: #444;
        }
        td, th
        {
            border: solid 1px #E6E6E6;
            padding-left: 3px;
        }
        th
        {
            background-color: #5B8;
        }
        .alternation
        {
            background-color: #D2FFD2;
        }
        .alternation3
        {
            background-color: #DDEEDD;
        }
        .selected
        {
            background-color: #B3E1A3;
        }
    </style>
     <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../css/css.css" />
    <link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css" />
    <link rel="stylesheet" type="text/css" href="../JqueryUI/themes/ui-lightness/jquery-ui-1.7.2.custom.css">
    <script type="text/javascript" src="../javascript/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="../javascript/jquery-ui-1.7.2.custom.js"></script>
    <script type="text/javascript" src="../javascript/formValidator.js"></script>
    <script type="text/javascript" src="../javascript/formValidatorRegex.js"></script>
    <script type="text/javascript" src="../javascript/Public.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/calendar.css" />
    <script type="text/javascript" src="../javascript/jquery-calendar.js"></script>
    <script type="text/javascript" src="../javascript/cal.js"></script>
    <!-- BEGIN  Select带可输入的功能  BEGIN -->

    <script type='text/javascript'>
        //定义 select 原值
        var oldValue, oldText;
        //select下拉框的onkeydown事件，修改下拉框的值
        function catch_keydown(sel) {
            switch (event.keyCode) {
                case 13: //回车键
                    event.returnValue = false;
                    break;
                case 27: //Esc键
                    sel.options[sel.selectedIndex].text = oldText;
                    sel.options[sel.selectedIndex].value = oldValue;
                    event.returnValue = false;
                    break;
                case 8:  //空格健
                    var s = sel.options[sel.selectedIndex].text;
                    s = s.substr(0, s.length - 1);
                    if (sel.options[0].value == sel.options[sel.selectedIndex].text) {
                        sel.options[sel.selectedIndex].value = s;
                        sel.options[sel.selectedIndex].text = s;
                    }
                    event.returnValue = false;
                    break;
            }
            if (!event.returnValue && sel.onchange)
                sel.onchange(sel)
        }

        //select下拉框的onkeypress事件，修改下拉框的值
        function catch_press(sel) {
            if (sel.selectedIndex == 0) {
                var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
                sel.options[sel.selectedIndex].value = s;
                sel.options[sel.selectedIndex].text = s;
                event.returnValue = false;
                if (!event.returnValue && sel.onchange)
                    sel.onchange(sel)
            }
        }

        //select下拉框的onfocus事件，保存下拉框原来的值
        function catch_focus(sel) {
            oldText = sel.options[sel.selectedIndex].value;
            oldValue = sel.options[sel.selectedIndex].value;
        }  
    </script>

    <!-- END    Select带可输入的功能  END-->
    <!-- BEGIN  画面的控制  BEGIN -->

    <script type='text/javascript'>
        $(document).ready(function() {


            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////
            //初始化数据
            GetOrganizationSumirise("SELECT");
            //初始化权限
            SetInitialRights();
            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////

            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////
            //权限设定
            function SetInitialRights() {
                //汇总权限
                if ($('#hddRights').val() != "1") {
                    $("#btnSummarys").css({ "display": "none" });

                }
                //查看其它单位权限
                if ($('#hddOpen').val() != "1") {
                    $("#btnOpen").css({ "display": "none" });

                }



            }
            //追加行常量
            function SetRowValue(strValue1, strValue2, strValue3, strValue4, strValue5, strValue6, strValue7, strValue8, strValue9, strValue10, strValue11, strValue12, strValue13, strValue14, strValue15, strValue16, strValue17, strValue18, strValue19, strValue20) {
                var strRowAdd = "<tr><td align='center'>a1</td><td style='display:none'>a2</td><td align='center'>a3</td><td align='center'>a4</td><td align='center'>a5</td><td align='center'>a6</td><td align='center'>a7</td><td align='center'>a8</td><td align='center'>a9</td><td align='center'>a10</td><td align='center'>a11</td><td align='center'>a12</td><td align='center'>a13</td><td align='center'>a14</td><td align='center'>a15</td><td align='center'>a16</td><td align='center'>a17</td><td  align='center' style='display:none;'>a18</td><td  align='center' style='display:none;'>a19</td><td  align='center' style='display:none;'>a20</td></tr>";
                return strRowAdd.replace("a1", strValue1).replace("a2", strValue2).replace("a3", strValue3).replace("a4", strValue4).replace("a5", strValue5).replace("a6", strValue6).replace("a7", strValue7).replace("a8", strValue8).replace("a9", strValue9).replace("a10", strValue10).replace("a11", strValue11).replace("a12", strValue12).replace("a13", strValue13).replace("a14", strValue14).replace("a15", strValue15).replace("a16", strValue16).replace("a17", strValue17).replace("a18", strValue18).replace("a19", strValue19).replace("a20", strValue20);
            }


            //追加行数据
            function SetAddRowDataValue(RowNo) {
                var strRemark = " ";
                var UninonId = $("#hddUnionID").val();
                //                return SetRowValue(RowNo,"",SetSelectValue(GetVipMemberList(UninonId), ""), SetDisEditSelectValue(GetSexList()), SetInputDefaultValue("", 2), SetSelectValue(GetVipMemberList(UninonId), ""), SetSelectValue(GetVipMemberList(UninonId), ""), SetSelectValue(GetVipMemberList(UninonId), ""), SetInputDefaultValue("", 10), SetInputDefaultValue("", 30));
                return SetRowValue(
                RowNo,
                $("#lblUnion").text(), //单位名称
                SetSelectValue(GetVipMemberList(UninonId), ""), //姓名
                SetDisEditSelectValue(GetSexList()), //性别
                SetInputDefaultValue("", 10), //投保时间
                SetInputDefaultValue("", 10), //投保金额
                SetInputDefaultValue("", 10), //补助时间1
                SetInputDefaultValue("", 10), //金额
                SetInputDefaultValue("", 10), //补助时间2
                SetInputDefaultValue("", 10), //金额
                SetInputDefaultValue("", 10), //补助时间3
                SetInputDefaultValue("", 10), //金额
                SetInputDefaultValue("", 10), //补助时间4
                SetInputDefaultValue("", 10), //金额
                SetInputDefaultValue("", 10), //补助时间5
                SetInputDefaultValue("", 10), //金额
                SetInputDefaultValue("", 50), //备注
                $("#hddUnionID").val(),
                "0",
                "0");
            }


            //对应业务信息
            function GetOrganizationSumirise(RightsFlg) {
                //清空明细显示
                $("#example>tbody>tr").each(function(i, item) {
                    if (i > 0) {
                        $(this).remove();
                    }
                });
                //明细赋值
                var strStrHtml = "";
                var queryString = "time=" + new Date() + "&TransFlg=MutualMemberSumirise" + "&RightsFlg=" + RightsFlg;
                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../ajaxGetJason.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: queryString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            var temp = eval(data);
                            if (temp) {
                                $.each(temp, function(i, item) {

                                    var strTr = "<tr style='height: 22px;'><td align='center'>" + (i + 1)
                                              + "</td><td style='display:none' >" + item["单位名称"]
                                              + "</td><td align='center'>" + item["姓名"]
                                              + "</td><td align='center'>" + item["性别"]
                                              + "</td><td align='center'>" + item["投保时间"]
                                              + "</td><td align='center'>" + item["投保金额"]
                                              + "</td><td align='center'>" + item["补助时间1"]
                                              + "</td><td align='center'>" + item["金额1"]
                                              + "</td><td align='center'>" + item["补助时间2"]
                                              + "</td><td align='center'>" + item["金额2"]
                                              + "</td><td align='center'>" + item["补助时间3"]
                                              + "</td><td align='center'>" + item["金额3"]
                                              + "</td><td align='center'>" + item["补助时间4"]
                                              + "</td><td align='center'>" + item["金额4"]
                                              + "</td><td align='center'>" + item["补助时间5"]
                                              + "</td><td align='center'>" + item["金额5"]
                                              + "</td><td align='left'>" + item["备注"]
                                              + "</td><td align='center' style='display:none;'>" + item["单位"]
                                              + "</td><td align='center' style='display:none;'>" + item["sex"]
                                              + "</td><td align='center' style='display:none;'>" + item["No"]
                                              + "</td></tr> "

                                    strStrHtml += strTr;
                                });
                                $("#example").append(strStrHtml);

                            } else {
                                if (RightsFlg == "SELECT") {
                                    var tr_id = $("#example>tbody>tr:last").find("td:eq(0)").text();
                                    if ($.trim(tr_id) == "序号" || $.trim(tr_id) == "") {
                                        tr_id = 0;
                                    }
                                    var id = parseInt(tr_id) + 1;
                                    $("#example").append(SetAddRowDataValue(id));

                                    AddRowEvent(id); //添加事件
                                } else {

                                    alert("没有找到相关数据");
                                }
                            }
                        }
                    });
            }


            function GetDataForSearch() {
                //清空明细显示
                $("#example>tbody>tr").each(function(i, item) {
                    if (i > 0) {
                        $(this).remove();
                    }
                });
                var RightsFlg = "Search";
                //明细赋值
                var strStrHtml = "";
                var queryString = "time=" + new Date() + "&TransFlg=MutualMemberSumirise" + "&RightsFlg=" + RightsFlg + "&theUnoinID=" + $("#hddSelectUnion").val() + "&theName=" + $("#hddSelectName").val();
                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../ajaxGetJason.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: queryString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            var temp = eval(data);

                            if (temp) {
                                $.each(temp, function(i, item) {

                                    var strTr = "<tr style='height: 22px;'><td align='center'>" + (i + 1)
                                              + "</td><td style='display:none' >" + item["单位名称"]
                                              + "</td><td align='center'>" + item["姓名"]
                                              + "</td><td align='center'>" + item["性别"]
                                              + "</td><td align='center'>" + item["投保时间"]
                                              + "</td><td align='center'>" + item["投保金额"]
                                              + "</td><td align='center'>" + item["补助时间1"]
                                              + "</td><td align='center'>" + item["金额1"]
                                              + "</td><td align='center'>" + item["补助时间2"]
                                              + "</td><td align='center'>" + item["金额2"]
                                              + "</td><td align='center'>" + item["补助时间3"]
                                              + "</td><td align='center'>" + item["金额3"]
                                              + "</td><td align='center'>" + item["补助时间4"]
                                              + "</td><td align='center'>" + item["金额4"]
                                              + "</td><td align='center'>" + item["补助时间5"]
                                              + "</td><td align='center'>" + item["金额5"]
                                              + "</td><td align='left'>" + item["备注"]
                                              + "</td><td align='center' style='display:none;'>" + item["单位"]
                                              + "</td><td align='center' style='display:none;'>" + item["sex"]
                                              + "</td><td align='center' style='display:none;'>" + item["No"]
                                              + "</td></tr> "

                                    strStrHtml += strTr;
                                });
                                $("#example").append(strStrHtml);

                            } else { alert("没有找到相关数据"); }
                        }
                    });
            }


            function AddRowEvent(intRowNo) {

                //投保时间
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(4)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //补助时间1
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(6)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //补助时间2
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(8)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //补助时间3
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(10)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //补助时间4
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(12)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //补助时间5
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(14)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });


            }
            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////


            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////
            //追加鼠标事件 行选择
            $('tbody > tr', $('#example')).live("click", function() {
                $('.selected').removeClass('selected');
                $(this).addClass('selected'); //this 表示引发事件的对象，但它不是 jquery 对象
                var tr_id = $(this).find("td:eq(0)").text();
                //对隐藏控件设定当前行的值
                $('#txtRowNo').val(tr_id);
            }).hover(		//注意这里的链式调用
					        function() {
					            $(this).addClass('mouseOver');
					        },
			        function() {
			            $(this).removeClass('mouseOver');
			        }
           );

            //取得当前选中行
            //            var myRows = $('table#example tr').live("click", function() {
            //                var tr_id = $(this).find("td:eq(0)").text();
            //                $('#txtRowNo').val(tr_id);
            //                //alert(myRows.index(this));
            //                //                //选择其他行时，编辑行恢复
            //                //                if ($('#txtRowNo').val() != editedID && editedID != "") {
            //                //                    var varValue = $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(1)").find("input").val();
            //                //                    var varValue1 = $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(2)").find("select").val();

            //                //                    $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(1)").find("input").remove();
            //                //                    $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(2)").find("select").remove();

            //                //                    $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(1)").append(varValue);
            //                //                    $("#example>tbody>tr:eq(" + editedID + ")").find("td:eq(2)").append(varValue1);
            //                //                };
            //            }
            //          );
            //行删除
            $('#btnDelete').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                if (!window.confirm("请确认是否删除记录。 ")) {
                    return;
                }
                var rows = $('#txtRowNo').val();
                var theID = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(19)").text();

                if (theID == '0') {
                    $("#example>tbody>tr:eq(" + rows + ")").remove();
                    $('#txtRowNo').val("");
                    var intRow = 1;
                    $("#example>tbody>tr").each(function(i, item) {
                        //跳过顶上的两行标题头
                        if (i > 0) {
                            //序号重新排序
                            $(this).find("td:eq(0)").text(intRow);
                            intRow++;
                        }
                    })
                } else {
                    var theDeleteString = "ID=" + theID //ID编号
                                       + "&UpdateFlg=" + "Update"
                                       + "&FormFlg=" + "MutualMemberSumirise";


                    $.ajax
            ({
                async: false,
                type: "post", //ajax请求方式
                url: "../AjaxDelete.aspx", //请求服务器地址
                datatype: "json", //希望数据库返回的数据类型
                data: theDeleteString, //发送给服务器的数据
                processData: false, //阻止数据被自动转换为url编码
                success: function(data) {//请求成功则调用该函数
                    if (data == "OK") {
                        $('#txtRowNo').val("");
                        $("#example>tbody>tr:eq(" + rows + ")").remove();
                        var intRow = 1;
                        $("#example>tbody>tr").each(function(i, item) {
                            //跳过顶上的两行标题头
                            if (i > 0) {
                                //序号重新排序
                                $(this).find("td:eq(0)").text(intRow);
                                intRow++;
                            }
                        })
                    }
                    else {
                        alert("删除失败！")
                    }
                }
            });
                }


            });

            //插入行
            $('#btnAdd').click(function() {
                var tr_id = $("#example>tbody>tr:last").find("td:eq(0)").text();
                if ($.trim(tr_id) == "序号" || $.trim(tr_id) == "") {
                    tr_id = 0;
                }
                var id = parseInt(tr_id) + 1;
                $("#example").append(SetAddRowDataValue(id));

                AddRowEvent(id); //添加事件
            });

            $("#datepanle").dialog({
                bgiframe: true,
                autoOpen: false,
                height: 260,
                modal: true,
                draggable: true,
                buttons: {
                    '提交': function() {

                        $("#hddState").val("1");

                        //获取所选择单位编号
                        var unionID = $("#dllUnion").val();

                        //设置选择的单位编号
                        $("#hddSelectUnion").val(unionID);

                        if (unionID == "0") {//如果选择所有单位 显示顶级单位
                            $("#lblUnion").text($("#hddAllName").val());
                        } else {

                            $("#lblUnion").text($("#dllUnion").find("option:selected").text()); //显示选择单位的名称
                        }
                        $("#hddSelectName").val($("#txtUserName").val()); //设置选择的名称

                        $(this).dialog('close');
                        GetDataForSearch();

                    },
                    '取消': function() {
                        $(this).dialog('close');
                    }
                },
                close: function() {
                    $("#txtUserName").val("");
                }
            });

            //插入行
            $('#btnSearch').click(function() {
                btnName = "Select";

                $("#datepanle").dialog('open');
            });

            //行编辑
            $('#btnEdit').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                var rows = $('#txtRowNo').val();
                //序号
                //单位
                //姓名
                editedContent2 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(2)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(2)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(2)").append(SetSelectValue(GetVipMemberList(GetUionListFirstId()), editedContent2));


                //性别
                editedContent3 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").append(SetDisEditSelectValue(GetSexList(), editedContent3));

                //投保日期
                editedContent4 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").append(SetInputDefaultValue(editedContent4, 10));

                //投保金额
                editedContent5 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").append(SetInputDefaultValue(editedContent5, 10));

                //补助日期1
                editedContent6 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").append(SetInputDefaultValue(editedContent6, 10));

                //金额1
                editedContent7 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").append(SetInputDefaultValue(editedContent7, 10));

                //补助日期2
                editedContent8 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(8)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(8)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(8)").append(SetInputDefaultValue(editedContent8, 10));

                //金额2
                editedContent9 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(9)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(9)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(9)").append(SetInputDefaultValue(editedContent9, 10));

                //补助日期3
                editedContent10 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(10)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(10)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(10)").append(SetInputDefaultValue(editedContent10, 10));

                //金额3
                editedContent11 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(11)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(11)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(11)").append(SetInputDefaultValue(editedContent11, 10));
                //补助日期4
                editedContent12 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(12)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(12)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(12)").append(SetInputDefaultValue(editedContent12, 10));

                //金额4
                editedContent13 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(13)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(13)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(13)").append(SetInputDefaultValue(editedContent13, 10));
                //补助日期5
                editedContent14 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(14)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(14)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(14)").append(SetInputDefaultValue(editedContent14, 10));
                //金额5
                editedContent15 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(15)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(15)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(15)").append(SetInputDefaultValue(editedContent15, 10));
                //备注
                editedContent16 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(16)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(16)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(16)").append(SetInputDefaultValue(editedContent16, 30));
                //添加事件
                AddRowEvent(rows);
                editedID = rows;
            });

            /// <summary>
            /// <p><b>方法名：</b>CreateUpdateString</p>
            /// <p><b>概要説明:</b>ajax向后台传的参数，区分ID和子区分ID</p>
            /// <p><b>作者  :</b>程明亮</p>
            /// <p><b>日期  :</b>2009/07/24</p>
            /// <p><b>修正履历:</b></p>
            /// </summary>
            function CreateUpdateString() {

                var nos = "";
                //单位

                var unionID = "";
                //姓名
                var vipName = "";
                //性别

                var sex = "";
                //投保时间
                var insuretime = "";

                //投保金额
                var insureamount = "";

                //补助时间1
                var granttime1 = "";

                //补助金额1
                var grantamount1 = "";

                //补助时间2
                var granttime2 = "";

                //补助金额2
                var grantamount2 = "";

                //补助时间3
                var granttime3 = "";

                //补助金额3
                var grantamount3 = "";

                //补助时间4
                var granttime4 = "";

                //补助金额4
                var grantamount4 = "";

                //补助时间5
                var granttime5 = "";

                //补助金额5    
                var grantamount5 = "";

                //备注
                var Remark = ""


                $("#example").find("tr:not(:eq(0))").each(function() {

                    if ($(this).find('td:eq(2)').find('select').length > 0) {

                        //姓名                   
                        if ($(this).find('td:eq(2)').find('select').length > 0) {
                            vipName = vipName + $(this).find('td:eq(2)').find('select').val() + ",";

                        }
                        else {
                            vipName = vipName + $(this).find('td:eq(2)').text() + ",";
                        }


                        //性别
                        if ($(this).find('td:eq(3)').find('select').length > 0) {
                            sex = sex + $(this).find('td:eq(3)').find('select').val() + ",";
                        }
                        else {
                            sex = sex + $(this).find('td:eq(18)').text() + ",";
                        }

                        //投保时间
                        if ($(this).find('td:eq(4)').find('input').length > 0) {
                            insuretime = insuretime + $(this).find('td:eq(4)').find('input').val() + ",";
                        }
                        else {
                            insuretime = insuretime + $(this).find('td:eq(4)').text() + ",";
                        }

                        //投保金额
                        if ($(this).find('td:eq(5)').find('input').length > 0) {
                            insureamount = insureamount + $(this).find('td:eq(5)').find('input').val() + ",";
                        }
                        else {
                            insureamount = insureamount + $(this).find('td:eq(5)').text() + ",";
                        }

                        //补助时间1
                        if ($(this).find('td:eq(6)').find('input').length > 0) {
                            granttime1 = granttime1 + $(this).find('td:eq(6)').find('input').val() + ",";
                        }
                        else {
                            granttime1 = granttime1 + $(this).find('td:eq(6)').text() + ",";
                        }

                        //补助金额1
                        if ($(this).find('td:eq(7)').find('input').length > 0) {
                            grantamount1 = grantamount1 + $(this).find('td:eq(7)').find('input').val() + ",";
                        }
                        else {
                            grantamount1 = grantamount1 + $(this).find('td:eq(7)').text() + ",";
                        }

                        //补助时间2
                        if ($(this).find('td:eq(8)').find('input').length > 0) {
                            granttime2 = granttime2 + $(this).find('td:eq(8)').find('input').val() + ",";
                        }
                        else {
                            granttime2 = granttime2 + $(this).find('td:eq(8)').text() + ",";
                        }

                        //补助金额2
                        if ($(this).find('td:eq(9)').find('input').length > 0) {
                            grantamount2 = grantamount2 + $(this).find('td:eq(9)').find('input').val() + ",";
                        }
                        else {
                            grantamount2 = grantamount2 + $(this).find('td:eq(9)').text() + ",";
                        }


                        //补助时间3
                        if ($(this).find('td:eq(10)').find('input').length > 0) {
                            granttime3 = granttime3 + $(this).find('td:eq(10)').find('input').val() + ",";
                        }
                        else {
                            granttime3 = granttime3 + $(this).find('td:eq(10)').text() + ",";
                        }

                        //补助金额3
                        if ($(this).find('td:eq(11)').find('input').length > 0) {
                            grantamount3 = grantamount3 + $(this).find('td:eq(11)').find('input').val() + ",";
                        }
                        else {
                            grantamount3 = grantamount3 + $(this).find('td:eq(11)').text() + ",";
                        }

                        //补助时间4
                        if ($(this).find('td:eq(12)').find('input').length > 0) {
                            granttime4 = granttime4 + $(this).find('td:eq(12)').find('input').val() + ",";
                        }
                        else {
                            granttime4 = granttime4 + $(this).find('td:eq(12)').text() + ",";
                        }

                        //补助金额4
                        if ($(this).find('td:eq(13)').find('input').length > 0) {
                            grantamount4 = grantamount4 + $(this).find('td:eq(13)').find('input').val() + ",";
                        }
                        else {
                            grantamount4 = grantamount4 + $(this).find('td:eq(13)').text() + ",";
                        }

                        //补助时间5
                        if ($(this).find('td:eq(14)').find('input').length > 0) {
                            granttime5 = granttime5 + $(this).find('td:eq(14)').find('input').val() + ",";
                        }
                        else {
                            granttime5 = granttime5 + $(this).find('td:eq(14)').text() + ",";
                        }

                        //补助金额5
                        if ($(this).find('td:eq(15)').find('input').length > 0) {
                            grantamount5 = grantamount5 + $(this).find('td:eq(15)').find('input').val() + ",";
                        }
                        else {
                            grantamount5 = grantamount5 + $(this).find('td:eq(15)').text() + ",";
                        }


                        //备注
                        if ($(this).find('td:eq(16)').find('input').length > 0) {
                            Remark = Remark + $(this).find('td:eq(16)').find('input').val() + ",";
                        }
                        else {
                            Remark = Remark + $(this).find('td:eq(16)').text() + ",";
                        }
                        unionID = unionID + $(this).find('td:eq(17)').text() + ",";

                        nos = nos + $(this).find('td:eq(19)').text() + ",";
                    }
                })

                var queryString = "Union=" + unionID
                               + "&vipName=" + vipName
                               + "&sex=" + sex
                               + "&insuretime=" + insuretime
                               + "&insureamount=" + insureamount
                               + "&granttime1=" + granttime1
                               + "&grantamount1=" + grantamount1
                               + "&granttime2=" + granttime2
                               + "&grantamount2=" + grantamount2
                               + "&granttime3=" + granttime3
                               + "&grantamount3=" + grantamount3
                               + "&granttime4=" + granttime4
                               + "&grantamount4=" + grantamount4
                               + "&granttime5=" + granttime5
                               + "&grantamount5=" + grantamount5
                               + "&nos=" + nos
                              + "&Remark=" + Remark
                              + "&UpdateFlg=" + "Update"
                              + "&FormFlg=" + "MutualMemberSumirise";
                return queryString;
            };

            //提交画面所有数据
            $('#btnSave').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可保存的数据！");
                    return;
                }

                $.ajax
            ({
                async: false,
                type: "post", //ajax请求方式
                url: "../ajaxUpdate.aspx", //请求服务器地址
                datatype: "json", //希望数据库返回的数据类型
                data: CreateUpdateString(), //发送给服务器的数据
                processData: false, //阻止数据被自动转换为url编码
                success: function(data) {//请求成功则调用该函数
                    if (data == "OK") {
                        alert("更新成功！");
                        //                        var flog = "SELECT";
                        //                        if ($("#hddSumarry").val() == "1") {
                        //                            flog = "Summary";
                        //                        }
                        //
                        if ($("#hddState").val() == "1") {
                            GetDataForSearch();
                        } else {
                            GetOrganizationSumirise("SELECT");
                        }

                    }
                    else {
                        alert("更新失败！")
                    }
                }
            });

            });

            //单位选择画面
            $('#btnOpen').click(function() {
                window.showModalDialog("../Common/SelectUnion.aspx?Random=" + Math.random(), window, "dialogWidth:300px;dialogHeight:590px;status=no;help=no;scroll:no");
                var submitForm = document.getElementById("mainForm");
                submitForm.submit();
                //清空当前行号
                $('#txtRowNo').val("");
            });

            //汇总
            $('#btnSummarys').click(function() {
                GetOrganizationSumirise("Summary");
                //汇总区分
                $('#hddSumarry').val("1");
            });


            //打印
            $('#btnPrintView').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可打印的数据！");
                    return;
                }
                if ($("#hddState").val() == "1") {
                    openwindow("MutualMemberSumirisePrint.aspx?Random=" + Math.random() + " &RightsFlg=" + "Search"+ "&theUnoinID=" + $("#hddSelectUnion").val() + "&theName=" + $("#hddSelectName").val(), 'newwindow', 1100, 500);
                }
                else {
                    openwindow("MutualMemberSumirisePrint.aspx?Random=" + Math.random() + " &RightsFlg=" + "SELECT", 'newwindow', 1100, 500);
                }
            });

            $('#btnExcelExport').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可导出的数据！");
                    return;
                }

                if ($("#hddState").val() == "1") {
                    window.open("../Common/ExcelExport.aspx?Random=" + Math.random() + "&TransFlg=MutualMemberSumirise" + "&Action=Search" + "&theUnoinID=" + $("#hddSelectUnion").val() + "&theName=" + $("#hddSelectName").val(), "win");
                }
                else {
                    window.open("../Common/ExcelExport.aspx?Random=" + Math.random() + "&TransFlg=MutualMemberSumirise" + "&Action=SELECT", "win");
                }
                
            });


            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////


        });
	
    </script>

    <!-- END    画面的控制  END   -->
</head>
<body>
    <form id="mainForm" runat="server">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="99%" cellpadding="0" cellspacing="0" class="table">
                    <tr>
                        <td valign="top">
                            <table width="100%" class="top" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="height: 22px;">
                                        &nbsp;<b>当前位置:</b>&nbsp;<a href="#">职工福利</a>&nbsp;>>&nbsp;<a href="#">职工互助保险补助情况统计</a><input
                                            id="txtRowNo" type="text" style="display: none" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td align="right" valign="middle" style="border: thin dotted #C0C0C0; background-color: #C5E5FC">
                            <img alt="" id="btnSearch" src="../images/button/btnSearch.gif" />
                            &nbsp;
                            <img alt="" id="btnOpen" src="../images/button/btnOpen.gif" />
                            &nbsp;
                            <img alt="" id="btnSave" src="../images/button/btnSave.gif" />
                            &nbsp;
                            <img alt="" id="btnPrintView" src="../images/button/btnPrint.gif" />
                            <!--&nbsp;
                            <img alt="" id="btnPrint" src="../images/button/btnPrintSet.gif" />-->
                            &nbsp;
                            <img alt="" id="btnAdd" src="../images/button/btnInsertRow.gif" />
                            &nbsp;
                            <img alt="" id="btnDelete" src="../images/button/btnDeleteRow.gif" />
                            &nbsp;
                            <img alt="" id="btnEdit" src="../images/button/btnEditRow.gif" />
                            &nbsp;
                            <img alt="" id="btnExcelExport" src="../images/button/btnExcelExport.gif" />
                            &nbsp;
                            <img alt="" id="btnSummarys" src="../images/button/btnSummary.gif" style="display: none" />
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 30px" align="center" class="style1">
                            <%=UnitRoot%>职工互助保险补助情况统计表
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div style="float: left; margin-left: 2px">
                                单位名称：<asp:Label ID="lblUnion" runat="server" /><input id="hddUnionID" type="hidden"
                                    runat="server" />
                            </div>
                            <div style="float: right; margin-right: 2px">
                                金额单位：元</div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            <table id='example' style="width: 100%; border-collapse: collapse;">
                                <!--<thead style="text-align:center;" >-->
                                <tr>
                                    <th style="width: 40px; height: 22px; background-color: #B2DBF7;" align="center">
                                        序号
                                    </th>
                                    <th style="display: none" align="center">
                                        单位名称
                                    </th>
                                    <th style="width: 95px; height: 22px; background-color: #B2DBF7;" align="center">
                                        姓名
                                    </th>
                                    <th style="width: 45px; height: 22px; background-color: #B2DBF7;" align="center">
                                        性别
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        投保时间
                                    </th>
                                    <th style="width: 70px; height: 22px; background-color: #B2DBF7;" align="center">
                                        投保金额
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        补助时间
                                    </th>
                                    <th style="width: 50px; height: 22px; background-color: #B2DBF7;" align="center">
                                        金额
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        补助时间
                                    </th>
                                    <th style="width: 50px; height: 22px; background-color: #B2DBF7;" align="center">
                                        金额
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        补助时间
                                    </th>
                                    <th style="width: 50px; height: 22px; background-color: #B2DBF7;" align="center">
                                        金额
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        补助时间
                                    </th>
                                    <th style="width: 50px; height: 22px; background-color: #B2DBF7;" align="center">
                                        金额
                                    </th>
                                    <th style="width: 90px; height: 22px; background-color: #B2DBF7;" align="center">
                                        补助时间
                                    </th>
                                    <th style="width: 50px; height: 22px; background-color: #B2DBF7;" align="center">
                                        金额
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        备注
                                    </th>
                                    <th align='center' style='display: none;'>
                                    </th>
                                    <th align='center' style='display: none;'>
                                    </th>
                                </tr>
                                <!--</thead>-->
                                <!--<tbody id='content'>-->
                                <!--</tbody>-->
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="hddRights" runat="server" />
    <asp:HiddenField ID="hddSumarry" runat="server" />
    <asp:HiddenField ID="hddOpen" runat="server" />
    <input id="hddState" type="hidden" value="0" />
    <input id="hddSelectUnion" type="hidden" />
    <input id="hddSelectName" type="hidden" />
    <asp:HiddenField ID="hddAllName" runat="server" />
    <div id="datepanle" title="查询条件">
        <fieldset>
            <div style="text-align: left; vertical-align: middle; margin: 5px">
                单位名称：<asp:DropDownList ID="dllUnion" runat="server">
                </asp:DropDownList>
                <div style="height: 9px">
                    &nbsp;</div>
                姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<input id="txtUserName" type="text" />
            </div>
        </fieldset>
    </div>

    <script type="text/javascript">
        $("#datepanle").hide();
    </script>

    </form>
</body>
</html>
